package com.weic.manager.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * request线程局部变量存取处理类
 */
public class ServletContextHolder {
    private static ThreadLocal<HttpServletRequest> requestThreadLocal = new ThreadLocal<HttpServletRequest>();

    /**
     * 获取request对象
     * @return
     */
    public static HttpServletRequest getRequest(){
        return requestThreadLocal.get();
    }

    /**
     * 设置请求对象
     * @param request
     */
    public static void setRequest(HttpServletRequest request){
        requestThreadLocal.set(request);
    }

    /**
     * 移除对象
     */
    public static void remove(){
        requestThreadLocal.remove();
    }
}
